package Searcher;

import java.util.ArrayList;
import java.util.List;

public class ProxySearcher extends ASearcher {

    private ASearcher aSearcher;

    private int[] useData;

    public ProxySearcher(ASearcher searcher, int[] users) {
        useData = users;
        aSearcher = searcher;
    }

    @Override
    public String doSearch(String userID, String keyWord) {
        String reString = "";
        if (!Validata(userID))
            reString += "错误的id\n\n";
        else {
            reString += aSearcher.doSearch(userID, keyWord);
        }
        return reString;
    }

    public boolean Validata(String userID) {
        boolean result = false;
        int id = Integer.valueOf(userID);
        for (int user : useData) {
            result = (user == id) || result;
        }
        return result;
    }

    public void Log(String userID) {
        System.err.println("用户" + userID + "查询成功\n\n");
    }
}
